import { defineStore } from 'pinia'
import { getNavRequest } from '@/service/module/home/home'
import { postAdminListRequest } from '@/service/module/admin/admin'

// interface IloginFace{
//     id: number,
//     title:string,
//     path: string,
//     name: string,
//     content:string,
// }
interface Inavdemo {
  iid: number
  path: string
  name: string
  title: string
  content: string
}
interface Iadmindemo {
  iid: number
  title: string
  paper: string
  image: string
  path: string
  name: string
  content: string
}

export const useLoginStore = defineStore('login', {
  state: () => ({
    navdemo: [] as Inavdemo[],
    admindemo: [] as Iadmindemo[],
    total: 0,
    iid: 0,
  }),

  getters: {
    // GET_TRAIN() {
    //     this.getTrainList()
    // }
  },
  actions: {
    //左侧导航栏
    async loginResult(iid: number) {
      await getNavRequest(iid).then((res) => {
        this.navdemo = res.data.data.findNavData

        console.log(res, '99999')
        // this.iid = res.data.data.findNavData.iid

        return Promise.resolve(undefined)
      })
    },

    //行测技巧列表数据
    async adminResultAction(adminlist: any) {
      const res = await postAdminListRequest(adminlist)

      this.admindemo = res.data.data.findAdminListData
      this.total = res.data.data.total
      console.log(res, '888888')
    },
  },
  persist: true,
})
